// Fill out your copyright notice in the Description page of Project Settings.

#pragma once

#include "CoreMinimal.h"
#include "Kismet/BlueprintFunctionLibrary.h"
#include "SimpleHttpFunctionLibrary.generated.h"

/**
 * 
 */
UCLASS()
class SIMPLEHTTPREQUEST_API USimpleHttpFunctionLibrary : public UBlueprintFunctionLibrary
{
	GENERATED_BODY()
public:

	UFUNCTION(BlueprintCallable, Category = "SimpleHttpLib")
	static bool SplitString(const FString& str, FString l, FString r, FString& out);

	UFUNCTION(BlueprintCallable, Category = "SimpleHttpLib")
	static bool SplitURLParameter(const FString& str, TMap<FString,FString>& out);

	UFUNCTION(BlueprintCallable, Category = "SimpleHttpLib")
	static bool SplitJsonParameter(const FString& str, TMap<FString, FString>& out);

	UFUNCTION(BlueprintCallable, Category = "SimpleHttpLib")
	static FString GetFMD5(const FString& fstring);

	UFUNCTION(BlueprintCallable, Category = "SimpleHttpLib")
	static FString ToBase64(const TArray<uint8>& data);

	UFUNCTION(BlueprintCallable, Category = "SimpleHttpLib")
	static FString StringToBase64(const FString& data);

	UFUNCTION(BlueprintCallable, Category = "SimpleHttpLib")
	static bool Base64ToData(const FString& df, TArray<uint8>& data);

	UFUNCTION(BlueprintCallable, Category = "SimpleHttpLib")
	static bool Base64StrToStr(const FString& df, FString& outStr, bool UrlSafe);

	UFUNCTION(BlueprintCallable, Category = "SimpleHttpLib")
	static void ChangeAddTo2B(FString& od);

	UFUNCTION(BlueprintCallable, Category = "SimpleHttpLib")
	static FString ChangeAddTo2B_(FString od);

	UFUNCTION(BlueprintCallable, Category = "SimpleHttpLib")
	static FString Utf8ToFString(const FString& str);

	UFUNCTION(BlueprintCallable, Category = "SimpleHttpLib")
	static FString GetGignature(const FString& policy, const FString& access_key);

	UFUNCTION(BlueprintCallable, Category = "SimpleHttpLib")
	static FString  base64_encode_urlsafe(FString str);

	UFUNCTION(BlueprintCallable, Category = "SimpleHttpLib")
	static bool SaveDataToDisk(const TArray<uint8>& data, FString str);

	UFUNCTION(BlueprintCallable, Category = "SimpleHttpLib")
	static bool SaveStringToDisk(const FString& data, FString str);

	UFUNCTION(BlueprintCallable, Category = "SimpleHttpLib")
	static FString ReplaceStr(const FString souse, FString from, FString tostr);

	UFUNCTION(BlueprintCallable, Category = "SimpleHttpLib")
	static bool StringToUint8(const FString& str, TArray<uint8>& data);

	UFUNCTION(BlueprintCallable, Category = "SimpleHttpLib")
	static FString Uint8ToString(const TArray<uint8>& outdata);

	UFUNCTION(BlueprintCallable, Category = "SimpleHttpLib")
	static bool MakeBodyData(FString Boundary, const TArray<FMKHttpBodyData>& bodyList
		, TArray<uint8>& outdata);

	UFUNCTION(BlueprintCallable, Category = "SimpleHttpLib")
	static FString GetSha256(const FString& str);

	UFUNCTION(BlueprintCallable, Category = "SimpleHttpLib")
	static FString ToUrlEncode(const FString& str);

	UFUNCTION(BlueprintCallable, Category = "SimpleHttpLib")
	static FString GetNowTickStr(int64 add = -28800000);

	UFUNCTION(BlueprintCallable, Category = "SimpleHttpLib")
	static FString UrlEncode(const FString& str);

	UFUNCTION(BlueprintCallable, Category = "SimpleHttpLib")
	static FString UrlDecode(const FString& urlCode);
	

	static FString GetSha256(const void* data, unsigned int numBytes);
};
